<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  created(){
    // 模拟接口数据 mock
    axios.get('/get_data').then(res => {
      console.log(res.data);
    });
    // 模拟接口数据 mock
    axios.post('/get_post').then(res => {
      console.log(res.data);
    });
    // 跨域请求, https://www.bilibili.com/index/ding.json
    // https://www.bilibili.com/index/ding.json  转换成 http://localhost:8080/api/index/ding.json
     axios.get('api/index/ding.json').then(res => {
      console.log('跨域请求的数据 = ',res.data);
    });
    // easymock 接口数据 mock
    axios.get('https://mock.mengxuegu.com/mock/6062d3a7f2e38f3a2f6ba1d3/example/mock').then(res => {
      console.log('EasyMock 数据 = ',res.data);
    });
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
